#include "Mini58Series.h"
#include "bsp_adc.h"
#include "bsp_led.h"
#include "bsp_motor.h"
#include "bsp_timer0.h"
#include "bsp_uart_fifo.h"

static void bsp_WDT_init(void) {
  SYS_UnlockReg();

  CLK->CLKSEL1 |= CLK_CLKSEL1_WDTSEL_Msk;
  CLK->APBCLK |= CLK_APBCLK_WDTCKEN_Msk;
  WDT->CTL = WDT_TIMEOUT_2POW14 | WDT_CTL_WDTEN_Msk | WDT_CTL_RSTEN_Msk |
             WDT_CTL_INTEN_Msk;

  SYS_LockReg();
}

void bsp_Init(void) {
  // bsp_WDT_init();
  bsp_InitUart();
  bsp_motor_Init();
  bsp_led_init();
  Timer0_InitHard();
  __set_PRIMASK(0);  //开总中断，在boot里关了总中断
}
